package cn.kenny.resource.mapper;

import cn.kenny.resource.entity.PageResult;
import cn.kenny.resource.pojo.Doc;
import cn.kenny.resource.pojo.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface DocMapper {

    @Select("select * from document")
    public Page<Doc> findAll();

    @Select("select * from document where dname = #{dname}")
    public Page<Doc> selectByCondition(String dname);

    @Insert("insert into document(name,size,ctime,uid,sid,path,dname,dsize)" +
            "values(#{name},#{size},#{ctime},#{uid},#{sid},#{path},#{dname},#{dsize})")
    public void add(Doc doc);

    @Delete("delete from document where id = #{id}")
    public Integer deleteById(@Param("id")Integer id);

    @Select("select * from document where id = #{id}")
    public Doc findById(@Param("id")Integer id);

    @Select("select * from document where uid = #{id}")
    public Page<Doc> findByUserId(@Param("id")Integer id);

    @Select("select * from document where sid = #{id}")
    public Page<Doc> findBySubjectId(@Param("id")Integer id);
}
